# Load all importance packages
import geopandas
import numpy as np
import pandas as pd
from shapely.geometry import Point
import missingno as msn
import seaborn as sns
import matplotlib.pyplot as plt
% matplotlib inline
country = geopandas.read_file("data/Neighbourhoods.geojson")
country.head()
country.plot(figsize=(30,20), color='#3B3C6E')
florence = pd.read_csv('data/df_cleaned.csv')
florence.head()
florence['coordinates'] = florence[['X', 'Y']].values.tolist()
florence.head()
florence['coordinates'] = florence['coordinates'].apply(Point)
florence.head()
florence = geopandas.GeoDataFrame(florence, geometry='coordinates')
florence.head()
florence.plot(figsize=(20,10));
fig, ax = plt.subplots(1, figsize=(130,200))
base = country.plot(ax=ax, color='Gray')
florence.plot(ax=base, color='Black', marker="*", markersize=100);
cam = pd.read_csv("data/Traffic Camera List.csv")
cam.head()
cam['coordinates'] = cam[['Longitude', 'Latitude']].values.tolist()
cam.head()
cam = cam.drop(['Group', 'Traffic Image', 'North Reference Static Image','East Reference Static Image','South Reference Static Image','West Reference Static Image'], axis=1)
cam
cam['coordinates'] = cam['coordinates'].apply(Point)
cam.head()
cam = geopandas.GeoDataFrame(cam, geometry='coordinates')
cam.head()
cam.plot(figsize=(20,10));
fig, ax = plt.subplots(1, figsize=(130,200))
base = country.plot(ax=ax, color='Gray')
florence.plot(ax=base, color='Black', marker="*", markersize=100);
# camera around toronto
cam.plot(ax=base, color='Red', marker="*", markersize=500);
be = ['Break and Enter']
florence2 = florence[florence.MCI.isin(be)]
florence2.head()
fig, ax = plt.subplots(1, figsize=(130,200))
base = country.plot(ax=ax, color='Gray')
florence2.plot(ax=base, color='Black', marker="*", markersize=100);
# camera around toronto
cam.plot(ax=base, color='Red', marker="*", markersize=500);
be = ['Auto Theft']
florence3 = florence[florence.MCI.isin(be)]
florence3.head()
fig, ax = plt.subplots(1, figsize=(130,200))
base = country.plot(ax=ax, color='Gray')
florence3.plot(ax=base, color='Black', marker="*", markersize=100);
# camera around toronto
cam.plot(ax=base, color='Red', marker="*", markersize=500);
fig, ax = plt.subplots(1, figsize=(130,200))
base = country.plot(ax=ax, color='Gray')
florence.plot(ax=base, color='Black', marker="*", markersize=100);
# camera around toronto
cam.plot(ax=base, color='Red', marker="*", markersize=500);
florence.plot(ax=base, column='MCI', marker=">", markersize=100, cmap='tab20c', label="Wind speed(mph)")
_ = ax.axis('off')
plt.legend()
ax.set_title("Toronto Map", fontsize=25)
plt.savefig('Toronto.png',bbox_inches='tight');